;*****************************************************
; 	Copyright (C) SEIKO EPSON CORP. 1997-2001
;	All rights Reserved
;
;	File name : memset.s
;	Function  :
;	       This is memset function
;	Revision  :
;		1997/03/25	V.Chan	start
;		1997/03/31	removed delayed jump after memory write (ln 31)
;		2001/12/06	T.Tazaki for GNU33(Linux)
;*****************************************************

;*****************************************************
; memset
;		copy char to first N bytes of dest
;
; arguments : %r6:dest addr, %r7:char, %r8:byte number
; return    : %r4:dest addr
;*****************************************************

	.section .text
	.align 1
	.global memset
	.type	memset,@function

memset:
	ld.w	%r4, %r6		; initialize result
			
memset_loop:
	cmp		%r8, 0
	jreq	memset_ret
	ld.b	[%r6]+, %r7	; add char to dest
	sub		%r8, 1		; decrement counter
	jp		memset_loop

memset_ret:
	ret

